/*
 * DragonGame.cpp
 *
 *  Created on: 2 nov. 2012
 *      Author: Ionel MOREAU-SEREZ
 */
#include"DragonGame.h"

// initialisation de lab, plan et chemin
void initialiser(DragonGame& d, ifstream& f){
	unsigned int dimX,dimY,dimZ;

	    f >> dimX;
		f >> dimY;
		f >> dimZ;
		//Lecture dimension des Labyrinthe3D

		initialiser(d.lab,dimX,dimY,dimZ,f);
		initialiser(d.plan,4,4);
		initialiser(d.chemin,4,4);
}

void detruire(DragonGame& d){
	detruire(d.lab);
	detruire(d.plan);
	detruire(d.chemin);

}


bool missionDragon(DragonGame& d, const IndexPosition3D& e){
	IndexPosition3D index;
	IndexPosition3D index2;

	 empiler(d.plan, e);
	 bool trouver = false;
	 while(trouve == false && !estVide(d.plan)){
		 index = sommet(d.plan);
		 depiler(d.plan);
	 }

	 //Maj connexe
	 index2 = lire(d.chemin, d.chemin.nb);
	 while(!estConnexe(index2,e)){
		 supprimer(d.chemin,d.chemin.nb);
	 }

	 ecrire(d.chemin, (d.chemin.nb+1), e);

	if (d.lab.t3D[e.i][e.j][e.k] != TRESOR){

		d.lab.t3D[e.i][e.j][e.k] != VISITEE;
		trouve = false;
	}
	else{
		trouve = true;
	}
	return trouve;
}


